#include "ccalldialer.h"
#include <QDebug>

CCallDialer::~CCallDialer()
{
    Cancel();
}
 
CCallDialer::CCallDialer( MDialObserver& aObserver, CTelephony* aTelephony ) :
    CActive( EPriorityNormal )
  ,iObserver( aObserver )
  ,iCallParamsPckg( iCallParams )
  ,iTelephony(aTelephony)
{
    CActiveScheduler::Add( this );
}

void CCallDialer::Call( const TDesC& aNumber )
{
    CTelephony::TTelNumber telNumber( aNumber ); 
    iCallParams.iIdRestrict = CTelephony::ESendMyId;    
    iTelephony->DialNewCall( iStatus, iCallParamsPckg, telNumber, iCallId );
    SetActive();  
}
 
void CCallDialer::RunL() {
    if(iStatus==KErrNone){
        iObserver.CallDialedL( iStatus.Int() );
    }
}
 
void CCallDialer::DoCancel() {
    iTelephony->CancelAsync( CTelephony::EDialNewCallCancel );
}
